<?php

 /*** include the controller class ***/
 include __SITE_PATH . '/application/' . 'controller_base.class.php';

 /*** include the registry class ***/
 include __SITE_PATH . '/application/' . 'registry.class.php';

 /*** include the router class ***/
 include __SITE_PATH . '/application/' . 'router.class.php';

 /*** include the template class ***/
 include __SITE_PATH . '/application/' . 'template.class.php';

 /*** auto load model classes ***/
    function __autoload($class_name) {
        $filename = strtolower($class_name) . '.class.php';
        $file = __SITE_PATH . '/model/' . $filename;
    
        if (file_exists($file) == false)
        {
            return false;
        }
      include ($file);
    }
    
    function get_server() {
    	$protocol = 'http';
    	if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
    		$protocol = 'https';
    	}
    	$host = $_SERVER['HTTP_HOST'];
        if($host == "localhost")
            $host .= "/photro";
    	$baseUrl = $protocol . '://' . $host;
    	return $baseUrl;
    }

 /*** a new registry object ***/
 $registry = new registry;


    function checkMode(){
        if($_SERVER['HTTP_HOST'] == "localhost")
            return false;
        else
            return true;
    }

define("__SERVER", get_server());
define("__VIEWS", __SERVER."/views");
date_default_timezone_set('Asia/Ho_Chi_Minh');
?>
